<!--
 * @Author: your name
 * @Date: 2021-12-08 11:26:24
 * @LastEditTime: 2022-02-26 10:30:58
 * @LastEditors: 雪球
 * @Description: 历史数据监测
-->
<template>
  <div class="butt-list-sty">
    <div
      v-for="(item, index) in topitemSelectList"
      :key="item.itemTypeId"
      :class="index === itemtypeactive ? 'basebut1' : 'basebut2'"
      @click="itemtypeactive = index"
    >
      <!-- @click="itemtypeactive = index" -->
      {{ item.energyName }}
    </div>
  </div>
</template>
<script>
// import baseQuery from "@/api/digital-operation/base"
import req from "@/api/digital-operation/detection-manage-ment/detection-type-manage";
export default {
  data() {
    return {
      itemtypeactive: 0,
      topitemSelectList: []
    };
  },
  watch: {
    itemtypeactive(newvalue) {
      this.selbut(newvalue);
    }
  },
  created() {},
  mounted() {
    this.getdata();
  },
  methods: {
    selbut(i) {
      this.$emit(
        "topitemtype",
        this.topitemSelectList[i]["energyTypeId"],
        this.topitemSelectList[i]["energyCoding"]
      );
    },
    getdata() {
      let params = {
        entity: {},
        page: 1,
        size: 1000
      };
      req.getEnergyType(params).then((res) => {
        if (res.code === 1) {
          let data = res.data || {};
          this.topitemSelectList = data.content || [];
          if (this.topitemSelectList.length > 0) {
            this.selbut(0);
          }
          // console.log(this.topitemSelectList);
        } else {
          this.$message.error(res.msg);
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.butt-list-sty {
  width: 100%;
  height: 35px;
  display: flex;
  position: relative;
  // top: 50%;
  // transform: translateY(50%);
  flex-direction: row;
}
.basebut1 {
  width: 120px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  // background-color: transparent;
  background-image: linear-gradient(#0fa1d2, #1087af, #106f8f);
  border: #f6f9f9 1px solid;
  border-radius: 15px;
  color: #ffffff;
  cursor: pointer;
  margin: 3px 5px;
  transform: translateY(50%);
}
.basebut2 {
  width: 120px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  background-color: #106986;
  border-radius: 15px;
  color: #ffffff;
  cursor: pointer;
  margin: 3px 5px;
  padding-left: 10px;
  padding-right: 10px;
  transform: translateY(50%);
}
</style>
